package com.RMP
{
    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import com.greensock.*;

    public class HoverImage extends Sprite
    {
        var loader:Loader;
        var imagePath:String;
        var fadeSpeed:Number;
        public var dbId:int;
        public var btnOver:Sprite;
        var image:Bitmap;
        var imageBorder:String;
        public var idNum:Number;
        public var btn:Sprite;
        var frame:Frame;
        var firstTime:Boolean = true;
        var myRoot:MovieClip;
        var isLoading:Boolean = false;
        public var shortText:ShortText;
        var myText:String;

        public function HoverImage(param1:MovieClip, param2:Number) : void
        {
            isLoading = false;
            firstTime = true;
            myRoot = param1;
            fadeSpeed = param2 / 3;
            return;
        }

        public function loadNewImage(param1:String) : void
        {
            if (loader != null)
            {
                loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoadComplete);
                loader = null;
            }
            loader = new Loader();
            loader.load(new URLRequest(myRoot.path + param1));
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
            return;
        }

        function onLoadComplete(event:Event) : void
        {
            var event:* = event;
            isLoading = false;
            if (image == null)
            {
                image = Bitmap(loader.content);
                image.alpha = 0;
                addChild(image);
                TweenMax.to(image, fadeSpeed, {alpha:1, overwrite:true, onComplete:function ()
            {
                image.smoothing = true;
                return;
            }
            });
            }
            else
            {
                image.smoothing = false;
                TweenMax.to(image, fadeSpeed, {alpha:0, overwrite:true, onComplete:function ()
            {
                removeChild(image);
                image = null;
                image = Bitmap(loader.content);
                image.alpha = 0;
                addChild(image);
                TweenMax.to(image, fadeSpeed, {alpha:1, overwrite:true, onComplete:function ()
                {
                    image.smoothing = true;
                    return;
                }
                });
                return;
            }
            });
            }
            return;
        }

        public function fadeInShell() : void
        {
            TweenMax.to(this, fadeSpeed, {alpha:1, overwrite:true});
            return;
        }

    }
}
